import {create} from 'zustand'
const authKey = `${import.meta.env.VITE_APP_AUTH_KEY || "authKey"}`;

interface Account {
    userName?: string,
    avatar?: string,
    isLogin: ()=>boolean,
    setLogin: (jwt: string) => void,
    logOut: () => void,

}

export const useAccountStore = create<Account>()(
    (set) => ({
        userName: '',
        avatar: '',
        isLogin: () => !!localStorage.getItem(authKey),
        setLogin: (jwt: string) => localStorage.setItem(authKey, jwt),
        logOut: () => localStorage.removeItem(authKey),
    })
)